// pages/demo/demo.js
import {
  getVehicle
} from '../../../api/vehicle.js';

Page({
  jump: function () {
    wx.navigateTo({
      url: '/pages/vehicle/details/details',
    })
  },
  //   request(params){
  //     wx.request({
  //         url: '/parking-api/vehicle/listUserVehicle',
  //         method:'GET',

  //         header: {
  //             "content-type":"applion/json",
  //             "appkey":config.appkey,
  //             "token":"eyJhbGciOiJIUzI1NiJ9.eyJtb2JpbGUiOiIwMDAwMDAwMCIsImlzcyI6IjE0MTIyMjM2NjQxODc4NjcxMzciLCJtZW1iZXJOYW1lIjoi6K-35L-u5pS555So5oi35ZCNIiwic2l0ZUlkIjoiQkwyMDIxMDEiLCJzaXRlTmFtZSI6IuWunemcsuWFrOWPuCIsImV4cCI6MTYyNjI5NzYxMiwiaWF0IjoxNjI1Nzk3NjEyLCJtZW1iZXJJZCI6IjE0MTIyMjM2NjQxODc4NjcxMzcifQ.mjdiS5VFICaaw7zAVH5WEERKfQXxVkiThyVlROXj14I"
  //         },
  //         success:(res)=>{
  //            console.log(res)
  //             }  
  //     })
  // },

  /**
   * 页面的初始数据
   */
  "code": "00000",
  data: {
    //遮盖层选择车型
    index: 0,
    multiArray: [
      ['轿车', '跑车', 'SUV', 'MPV', '面包', '皮卡', '卡车', '客车'],
      ['微型轿车', '小型轿车', '紧凑型轿车', '中级轿车', '中高级轿车', '高级轿车', '豪华轿车']
    ],
    objectMultiArray: [
      [{
          id: 0,
          name: '轿车'
        },
        {
          id: 1,
          name: '跑车'
        },
        {
          id: 2,
          name: 'SUV'
        },
        {
          id: 3,
          name: 'MPV'
        },
        {
          id: 4,
          name: '面包'
        },
        {
          id: 5,
          name: '皮卡'
        },
        {
          id: 6,
          name: '卡车'
        },
        {
          id: 7,
          name: '客车'
        }
      ],
      [{
          id: 0,
          name: '微型轿车'
        },
        {
          id: 1,
          name: '小型轿车'
        },
        {
          id: 2,
          name: '紧凑型轿车'
        },
        {
          id: 3,
          name: '中级轿车'
        }, {
          id: 4,
          name: '中高级轿车'
        }, {
          id: 5,
          name: '高级轿车'
        }, , {
          id: 6,
          name: '豪华轿车'
        },
      ]
    ],
    multiIndex: [0, 0],
    showModalStatus: true,
    customItem: '全部',
    //绑定链接前后端数据
    vehicleImg_2: '/images/Rectangle 95.png',
    vehicleImg: '/images/image 2.png',
    vehicleList: [{
        "vehicleBrand": "大众1",
        "vehicleId": "14119808513407139852",
        "vehicleImg_2": '/resource/images/Rectangle 95.png',
        "vehicleImg": '/resource/images/image 1.png',
        "vehicleNumber": "粤A·123456",
        "vehicleType": "START"
      },
      {
        "vehicleBrand": "大众",
        "vehicleId": "1411980851340713985",
        "vehicleImg": '/resource/images/image 2.png',
        "vehicleImg_2": '/resource/images/Rectangle 104.png',
        "vehicleNumber": "粤A·201453",
        "vehicleType": "START"
      }
    ],
  },
  bindMultiPickerColumnChange: function (e) {
    console.log('修改的列为', e.detail.column, '，值为', e.detail.value);
    var data = {
      multiArray: this.data.multiArray,
      multiIndex: this.data.multiIndex
    };
    data.multiIndex[e.detail.column] = e.detail.value;
    switch (e.detail.column) {
      case 0:
        switch (data.multiIndex[0]) {
          case 0:
            data.multiArray[1] = ['微型轿车', '小型轿车', '紧凑型轿车', '中级轿车', '中高级轿车', '高级轿车', '豪华轿车'];
            break;
          case 1:
            data.multiArray[1] = ['普通跑车', '中级跑车', '高级跑车', '豪华跑车', '超级跑车'];
            break;
          case 2:
            data.multiArray[1] = ['微型SUV', '轻型SUV', '小型SUV', '中型SUV', '大型SUV', '豪华SUV', '专业SUV', '紧凑型SUV'];
            break;
          case 3:
            data.multiArray[1] = ['小型MPV', '普通MPV', '中高级MPV', '豪华MPV'];
            break;
          case 4:
            data.multiArray[1] = ['微型面包车', '普通面包车', '中高级面包车', '豪华面包车'];
            break;
          case 5:
            data.multiArray[1] = ['低档卡车', '中档卡车', '高档卡车', '超级卡车'];
            break;
          case 6:
            data.multiArray[1] = ['小卡', '轻卡', '中卡', '重卡', '专用车'];
            break;
          case 7:
            data.multiArray[1] = ['中巴车', '城市客车', '长途客车'];
            break;
        }
        data.multiIndex[1] = 0;
        data.multiIndex[2] = 0;
        break;


        data.multiIndex[2] = 0;
        break;
    }
    console.log(data.multiIndex);
    this.setData(data);
  },
  onChange({
    detail
  }) {
    // 需要手动对 checked 状态进行更新
    this.setData({
      checked: detail
    });
  },
  onLoad: function (options) {},
  //点击我显示底部弹出框
  clickme: function () {
    this.showModal();
  },

  //显示对话框
  showModal: function () {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
      showModalStatus: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 200)
  },
  //隐藏对话框
  hideModal: function () {
    // 隐藏遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        showModalStatus: false
      })
    }.bind(this), 200)
  },

  //点击我显示底部弹出框
  clickme: function () {
    this.showModal();
  },

  //显示对话框
  showModal: function () {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
      showModalStatus: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 200)
  },
  //隐藏对话框
  hideModal: function () {
    // 隐藏遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        showModalStatus: false
      })
    }.bind(this), 200)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(res=>{
    //   this.data.vehicleBrand=vehicleBrand
    // })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})